package com.nju.usayit.bitmap.core;

import android.content.Context;

/**
 * 鐢ㄤ簬鍒ゆ柇褰撳墠绯荤粺鐨勭増鏈� * 
 * @author michael yang 鍦╯dk4.1涓嬬紪璇戞墠鑳介�杩� */
public class Utils {
	private Utils() {
	};

	
	/**
	 * 鏍规嵁鎵嬫満鐨勫垎杈ㄧ巼浠�dp 鐨勫崟浣�杞垚涓�px(鍍忕礌)
	 */
	public static int dip2px(Context context, float dpValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (dpValue * scale + 0.5f);
	}

	/**
	 * 鏍规嵁鎵嬫満鐨勫垎杈ㄧ巼浠�px(鍍忕礌) 鐨勫崟浣�杞垚涓�dp
	 */
	public static int px2dip(Context context, float pxValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (pxValue / scale + 0.5f);
	}
}
